package com.hcloud.libupload.comom

import com.hcloud.libupload.task.UploadTask
import retrofit2.Call
import java.util.concurrent.ThreadPoolExecutor

class TaskControl(private val taskPool: ThreadPoolExecutor) {


    var uploadTask: UploadTask? = null

    var call: Call<*>? = null
    var putCall = mutableListOf<Call<*>>()


    // has callback
    fun cancel() {
        uploadTask?.partPool?.queue?.clear()
        taskPool.remove(uploadTask)
        call?.cancel()
        for (call in putCall) {
            call.cancel()
        }
        putCall.clear()
        call = null
    }
}